package com.java.util;

import javax.servlet.http.Cookie;

/**
 * @author jingjintao
 * @date 2021/6/20 - 0:02
 **/
public class CookieUtils {
    /**
     * 根据名称查找需要的cookie
     * @param name
     * @param cookies
     * @return
     */
    public static Cookie findCookie(String name, Cookie[] cookies){
        if(name == null || cookies == null || cookies.length ==0){
            return null;
        }

        for (Cookie cookie : cookies) {
            if(name.equals(cookie.getName())){
                return cookie;
            }
        }
        return null;
    }
}
